<!DOCTYPE html>
<html>
<head>
    <title>车位选择</title>
    <#include "../common/common.ftl"/>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space10">
        <div class="layui-col-xs12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <form class="layui-form" id="searchForm">
                        户号：
                        <div class="layui-inline" style="width: 100px;">
                            <input class="layui-input" name="search_like_string_c.houseNum" autocomplete="off">
                        </div>
                        <button class="layui-btn" type="button" id="searchButton"><i class="layui-icon layui-icon-search"></i>搜索</button>
                    </form>
                    <table id="dataTable" class="layui-table" lay-filter="layFilter"></table>
                    <!--序号-->
                    <script type="text/html" id="indexTpl">
                        {{d.LAY_TABLE_INDEX+1}}
                    </script>
                    <!--菜单-->
                    <script type="text/html" id="dataTable_toolbar">
                        {{# if(d.houseStatus == 1){ }}
                        <a class="layui-btn layui-btn-xs" lay-event="dataTable_select">预选</a>
                        {{#  } }}
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/layui/layui.js" charset="utf-8"></script>
<script>
    layui.config({
        base: '/modules/' //静态资源所在路径
    }).use(['table', 'form', 'jmdf','jquery', 'page','layer','dataDict'], function () {
        var $ = layui.jquery, jmdf = layui.jmdf, page = layui.page, table = layui.table, form = layui.form,layer = layui.layer,dataDict = layui.dataDict,
            parentIndex = parent.layer.getFrameIndex(window.name);

        /***********************table表格相关操作 start*************************/
        var tableRenderId = "renderId";
        var tableId = "dataTable";
        var table_layFilter = "layFilter";
        var tableUrl = "loadCarLotList?contractId=${(contract.id)!}";

        dataDict.select("车位类型", "carLotTypeSelect", "");

        //列项内容
        var cols = [[
            {title: "序号", toolbar: '#indexTpl', fixed: 'left', align: 'center'}
            , {field: "houseNum", title: "户号", align: 'center',width:240}
            , {field: "projectName", title: "安置项目", align: 'center',width: 120}
            , {field: "floor", title: "所在层数", align: 'center'}
            , {field: "buildArea", title: "建筑面积(㎡)", align: 'center'}
            , {field: "carLotTypeStr", title: "车位类型", align: 'center'}
            , {
                field: "houseStatus", title: "车位状态", align: 'center',  templet: function (d) {
                    return d.houseStatusStr;
                }
            }
            , {title: '操作', fixed: 'right', align: 'center', toolbar: '#dataTable_toolbar',}
        ]];

        //table设置项
        var options = {
            elem: '#' + tableId//table列表id值
            , url: tableUrl
            , cols: cols
            , id: tableRenderId
            , defaultToolbar: false
            , autoSort: false //禁用前端自动排序。
        };

        //初始表格（含分页设置）
        page.render(options);
        //表格排序
        page.sort(tableId, tableRenderId);
        //刷新当前页方法封装
        page.reload();

        //分页查询（查询条件）
        $("#searchButton").click(function () {
            page.search("searchForm", tableRenderId);
        });

        form.render();

        table.on("tool(" + table_layFilter + ")", function (obj) {
            var data = obj.data;///获得当前行数据
            var layEvent = obj.event;//获得lay-event对应的值
            if (layEvent == "dataTable_select") {
                layer.open({
                    title: false, shade: 0.5, content: "确定预选【"+data['houseNum']+"】车位吗？", btn: ['确定', '取消'], closeBtn: 0, btnAlign: 'c'
                    , yes: function (index) {
                        $.get("yxCarLotSave", {contractId:"${(contract.id)!}",carLotId:data["id"],_time: new Date().getTime()}, function (data) {
                            if (data.code == "0001") {//成功
                                var map = data.data;
                                layer.msg(data.message, {anim: 0, icon: 1,time:1000},function(){
                                    parent.parent.reloadSelectYxCarLotInfo(map.contractId);
                                    parent.layer.close(parentIndex);
                                });
                            } else {//失败
                                layer.msg(data.message, {anim: 6, icon: 2,time:3000});
                                layer.close(parentIndex);
                            }
                            layer.close(parentIndex);
                        });
                    }
                });
            }
        });
    });
</script>
</body>
</html>